package com.zoke.password.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zoke.password.model.Password;
import com.zoke.password.R;

import java.util.List;

/**
 * Created by wulijie on 2018/5/31.
 */
public class PasswordAdapter extends BaseQuickAdapter<Password, BaseViewHolder> {
    public PasswordAdapter(@Nullable List<Password> data) {
        super(R.layout.item_password, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Password item) {
        int levelColor;
        switch (item.level) {
            case EASY:
                levelColor = R.drawable.shape_level_1;
                break;
            case MIDIUM:
                levelColor = R.drawable.shape_level_2;
                break;
            case STRONG:
                levelColor = R.drawable.shape_level_3;
                break;
            case VERY_STRONG:
            default:
            case EXTREMELY_STRONG:
                levelColor = R.drawable.shape_level_4;
                break;
        }
        helper.setBackgroundRes(R.id.iv_level, levelColor)
                .setText(R.id.tv_zh, item.account)
                .setText(R.id.tv_title, item.title);
    }
}
